﻿using EntityModels.Entities;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EntityModels.Configures
{
    /// <summary>
    /// 幕后字段
    /// </summary>
    public class BackingFieldsEntityConfiguration : IEntityTypeConfiguration<GeneratedValueEntity>
    {
        public void Configure(EntityTypeBuilder<GeneratedValueEntity> builder)
        {
            builder.Property(g => g.SummryInDatabase)
                .HasComputedColumnSql("N'Record id is ' + convert(nvarchar, [Id]) + N' and inserted on ' + convert(nvarchar, [InsertedOffset]) + N' by database.'", true)
                .HasField("_summryInDatabase")
                .UsePropertyAccessMode(PropertyAccessMode.PreferField);
        }
    }
}
